@extends('layouts.base')
@section('title', $movie->full_name)
@section('keyWords',$movie->full_name)
@section('description',$movie->full_name.'百度网盘 磁力衔接 bt种子 电驴 在线观看')
@section('content')

<div class="row">
        <div class="well">
            <h1 class="text-center" >{{$movie->full_name}}</h1>
            <div class="entry-meta text-muted">
                <span class="posted-on"><i class="glyphicon glyphicon-calendar"></i>
                    发布于
                    <time class="entry-date published" datetime="{{ $movie->created_at }}">{{ $movie->created_at->diffForHumans() }}</time>
                    ，最后更新于
                    <time class="entry-date last-updated" datetime={{ $movie->updated_at }}>{{ $movie->updated_at->diffForHumans() }}</time>
                </span>
                <span class="post-views" style="float:right;"><i class="glyphicon glyphicon-eye-open">&nbsp</i>{{$movie->vote->visit}} views</span>
            </div><!-- .entry-meta -->
            <div class="row">
                <div class="col-md-4">
                    <img class="img-responsive" src="{{$movie->coverage_image}}" alt="{{$movie->full_name}}">
                </div>
                <div class="col-md-8">

                    <p>{{$movie->detail}}</p>
                </div>

            </div>
        </div>
        <div class="well">
            {{--用户评分--}}
            <div class="row">
                <form class="form-horizontal">
                    <div class="form-group">
                        <label for="input-score" class="control-label col-md-5 lead">当前有<strong id="vote_count">{{$movie->vote->vote_count}}</strong>人评价平均分:</label>
                        <input id="input-score" name="input-name" type="number" class="rating col-md-7" value="{{$movie->vote->score}}"  min=0 max=5 step=0.1 data-size="sm" data-show-clear="false" data-show-caption="{{$movie->vote->score}}" data-readonly="true">
                    </div>
                    <div class="form-group">
                        <label for="input-rating" class="control-label col-md-5 lead">您的评分:</label>
                        <input id="input-rating" name="input-name" type="number" class="rating-loading col-md-7" min=0 max=5 step=0.1 data-size="sm" data-show-clear="false">
                    </div>
                </form>
            </div>
        </div>
        <div class="well">
                @foreach($movie->episodes as $episode)
                    <h3 class="text-center lead">
                        <a href="{{route('episode.show',$episode)}}">{{$episode->full_name}}</a>
                    </h3>

                    <p>
                        @if(strlen($episode->url_baidupan)>1)
                            <a href={{$episode->url_baidupan}}>
                                <span class="label label-success">度盘</span>
                            </a>
                            &nbsp &nbsp
                        @endif
                        @if(strlen($episode->url_torrent)>1)
                            <a href="{{$episode->url_torrent}}">
                                <span class="label label-warning">种子</span>
                            </a>
                            &nbsp &nbsp
                        @endif
                        @if(strlen($episode->url_magnet)>1)
                            <a href={{$episode->url_magnet}}>
                                <span class="label label-danger">磁力</span>
                            </a>
                            &nbsp &nbsp
                        @endif

                        @if(strlen($episode->url_ed2k)>1)
                            <a  href={{$episode->url_ed2k}}>
                                <span class="label label-info">电驴</span>
                            </a>
                            &nbsp &nbsp
                        @endif
                        @if(strlen($episode->url_other)>1)
                            <a  href={{$episode->url_other}}>
                                <span class="label label-default">其他</span>
                            </a>
                            &nbsp &nbsp
                        @endif
                    </p>
                    <ul class="list-inline">

                        <li>
                            <strong>{{$episode->size}}</strong>&nbsp&nbsp&nbsp
                        </li>
                        <li>
                            <span>{{'创建时间:'.$episode->created_at->diffForHumans()}}</span>

                        </li>
                        <li>
                            <span>{{'创建时间:'.$episode->created_at}}</span>
                        </li>
                        <li>
                            <span>{{'更新时间:'.$episode->updated_at}}</span>
                        </li>
                    </ul>
                    <hr>
                @endforeach
        </div>
</div>

@endsection

@section('scripts')
    <script type="text/javascript">
        $(document).on('ready', function() {
            $('#input-rating').rating({clearCaption: '请评分'});
            $('#input-rating').on('rating.change', function (event, value, caption) {
                $.post("{{url('vote/forMovie')}}",
                        {
                            '_token': '{{csrf_token()}}',
                            id: "{{$movie->id}}",
                            score: value
                        },
                        function (data, status) {
                            var returnScore = data.score.toFixed(2);
                            $('#input-score').rating('update', returnScore);
                            $('#input-rating').rating('refresh', {disabled: true, showClear: false, showCaption: true});
                            $('#vote_count').text(data.vote_count);
                        });
            });
        })
    </script>

@endsection
